
import java.util.Arrays;
import java.util.Scanner;
interface IntegerStack<Integer>{
	public Integer push(Integer item);
	public Integer pop();
	public Integer peek(); 
	public boolean empty(); 
	public int size(); 
}
class ArrayIntegerStack implements IntegerStack<Integer>{
	Integer[] t;
	private int top = -1;
	
	
	public ArrayIntegerStack(int i) {
	/*if(i>=0){
		this.t=new Integer[i];
		this.maxSize=i;
		this.top=-1;
		}*/
		t=new Integer[i];
	}
	
	
	public Integer[] getT() {
		return t;
	}


	public void setT(Integer[] t) {
		this.t = t;
	}


	/*public boolean isEmpty(){
		return top == -1 ? true : false;
	}
	public boolean isMax(){
		return top >= maxSize-1 ? true : false;
	}*/
	public Integer push(Integer item) {
		if(item==null||this.size()>=t.length){
			return null;
		}
		top++;
		t[top]=item;
	
		return item;
	}
	public Integer pop() {
		if(this.empty()){
			return null;
		}
		Integer e=t[top];
		top--;
		return e;
	}

	@Override
	public Integer peek() {
		if(this.empty()){
			return null;
		}
		return t[top];
	}

	@Override
	public boolean empty() {
		// TODO Auto-generated method stub
		return top==-1?true:false;
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return this.top+1;
	}
	
}


	

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in 

);
		int n=Integer.parseInt(sc.nextLine());
		ArrayIntegerStack stack=new ArrayIntegerStack(n);
		int m=Integer.parseInt(sc.nextLine());
		String y=sc.nextLine();
		String[] str=y.split(" ");
		int x=Integer.parseInt(sc.nextLine());
		for (int i = 0; i < m; i++){
			int q=Integer.parseInt(str[i]);
			System.out.println(stack.push(q));
		}
		System.out.println(stack.peek()+","+stack.empty()+","+stack.size());
		System.out.println(Arrays.toString(stack.getT()));
		for (int i = 0; i < x; i++) {
			System.out.println(stack.pop());
		}
		System.out.println(stack.peek()+","+stack.empty()+","+stack.size());
		System.out.println(Arrays.toString(stack.getT()));
	}

}